// const axios = require('axios')
const fs = require('fs')
const FormData = require('form-data')

const formData = new FormData()
formData.append('file', fs.createReadStream('E:\\毕业设计\\----\\论文资料\\开题报告.docx'))
// console.log(formData)
const conditions = {
  host: 'localhost',
  path: '/learningSpace/user/upload',
  port: 3000,
  headers: {
    authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ijh4S0dIVTFNIiwiaWF0IjoxNjE4NDYwODUwLCJleHAiOjE2MTg0NjQ0NTB9.VSiIdkJaJa0X2n0gOShpxzINjwV4V_Zv5ae7A3KwEno'
  }
}
formData.submit(conditions, (error, response) => {
  if (!error) {
    console.log(response)
  } else {
    console.log(error.message)
  }
})

// const instance = axios.create({
//   headers: {
//     authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ijh4S0dIVTFNIiwiaWF0IjoxNjE4NDYyNjUyLCJleHAiOjE2MTg0NjYyNTJ9.Rub1sF2zxaLmRrZoQW7ONvSUqWkFVLC_cPqxCtwqTFA',
//     'Content-Type': 'multipart/form-data'
//   },
//   baseURL: 'http://localhost:3000/learningSpace'
// })

// instance.post('/user/upload', formData).then((res) => { console.log(res) })
